package android.slc.mp.ui.page.photo;

import android.slc.mp.po.SelectEvent;
import android.slc.mp.po.i.IPhotoFolder;
import android.slc.mp.po.i.IPhotoItem;
import android.slc.mp.po.i.IPhotoResult;
import android.slc.mp.ui.SlcIMpDelegate;
import android.slc.mp.ui.page.SlcMpPagerBaseFragment2;
import android.slc.mp.ui.page.SlcMpPagerBaseVd;
import android.slc.mp.ui.page.SlcMpPagerVirtualVm;

/**
 * Created by slc
 */
public class SlcMpPagerPhotoFragment2 extends SlcMpPagerBaseFragment2<IPhotoResult, IPhotoFolder, IPhotoItem> {

    @Override
    public SlcMpPagerVirtualVm<IPhotoResult, IPhotoFolder, IPhotoItem> getMediaPickerListDelegate(int mediaType, SlcIMpDelegate slcIMpDelegate) {
        SlcMpPagerPhotoVirtualVm slcMpPagerPhotoDelegateImp = new SlcMpPagerPhotoVirtualVm(slcIMpDelegate) {
            @Override
            public Object onSelectEvent(int eventCode, SelectEvent event) {
                switch (eventCode) {
                    case SelectEvent.EVENT_CHECK:
                        IPhotoItem baseItem = event.getAuto(SelectEvent.PARAMETER_ITEM);
                        int position = getCurrentMediaList().indexOf(baseItem);
                        if (position >= 0) {
                            slcMpPagerBaseVd.onCheck(position, baseItem);
                        }
                        return null;

                }
                return super.onSelectEvent(eventCode, event);
            }
        };
        slcMpPagerPhotoDelegateImp.register(this);
        return slcMpPagerPhotoDelegateImp;
    }

    @Override
    protected SlcMpPagerBaseVd<IPhotoResult, IPhotoFolder, IPhotoItem> initSlcMpPagerVd() {
        return new SlcMpPagerPhotoVd();
    }

}
